<html>
    <head>
        <script type="text/javascript" src="stardust.js"></script>
        <script type="text/javascript" src="gmobjs.js"></script>
        <script type="text/javascript" src="particles.js"></script>
        <script type="text/javascript" src="medals.js"></script>
        <script type="text/javascript" src="game.js"></script>
        <div id='fb-root'></div>
        <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
            FB.init({appId:'151772394861544', status:true, cookie:true, xfbml:false});
            
            function publishData(){
                var publish = {
                    method: 'stream.publish',
                    message: 'Check out my Achievements in Stardust Game',
                    attachment: {
                        name: 'Stardust',
                        caption: 'The Stardust Achievements',
                        description:(medaltracker.getMedals()),
                        href: 'http://balaji.me/vkrishna/stardust',
                        media: [
                        {
                            type: 'image',
                            href: 'http://balaji.me/vkrishna/stardust/data',
                            src: 'http://balaji.me/vkrishna/stardust/data/pickup.png'
                        }
                        ]
                    },
                    action_links: [
                    { text: 'vkgamedev', href: 'http://sites.google.com/site/vkgamedev' }
                    ],
                    user_prompt_message: 'Brag about your stardust Achievements with your friends'
                };
                FB.ui(publish, function(res){
                    if(res && res.post_id){
                        //                            alert('done');
                        }else{
                        //                          alert('could not post');    
                    }
                });

            }

            function fblogin(response){
                if(response.session){
                    if(response.perms){
                        publishData();
                    }
                }
                else{
//                    alert('Could not login to FB');
                }
            }

            function BragAchievements(){
                var session = FB.getSession();
                if(session){
                    publishData();
                }
                else{
                    FB.login(fblogin, {perms:'publish_stream'});
                }
            }
        </script>
    </head>
    <body onLoad="InitScreen('stardust');">
        <center>
            <canvas id="stardust" style="border:solid 1px #000000;" width=640 height=480></canvas>
            <div id="fb" style="position:absolute;"> Brag On <img src="data/facebook_icons.png" style="width:64px; height:64px;" onClick="BragAchievements();"></img> </div>
            <div id="pbutton" style="border:solid 1px #000000; width:20px; height:25px; position:absolute;" onclick="pButtonClicked();">||</div>
            <div id="gmesg" style="border:dashed 1px #000000; width:640px; height:40px; position:absolute; background-color:#76d776;"></div>
            <div id="medal" style="border:dashed 1px #000000; width:250px; height:50px; position:absolute; background-color:#76d776;"></div>
            <p>
            <div id="medallist" style="border:dashed 1px #000000; width:640;" align="left"><u><b>Achievements:</b></u> </div>
            </p>
            developed by: <a href="http://sites.google.com/site/vkgamedev"><img src="data/Logo.gif" style="width:50px; heigth:50px;" alt="V.Vamsi Krishna"</img></a>
        </center>
    </body>
</html>
